<?php
error_reporting(E_ALL ^ E_NOTICE);
if(!file_exists("config/install.lock")){
	header("Location:install");exit;
};
header("Content-type:text/html; charset=utf-8");
define("ROOT_PATH",  str_replace("\\", "/", dirname(__FILE__))."/");
@include_once("config/setconfig.php");
@include_once("config/version.php");
 
require("config/rewriterule.php");
require("config/config.php");
require("config/const.php");

define("CONTROL_DIR","source/kucunadmin");
define("MODEL_DIR","source/model");
/*视图模版配置*/
$cache_dir="";//模版缓存文件夹
$wap_template_dir=$template_dir="themes/kucunadmin";//模版风格文件夹
$compiled_dir="";//模版编译文件夹
$html_dir="";//生成静态文件夹
$rewrite_on=REWRITE_ON;//是否开启伪静态 0不开 1开启
$smarty_caching=true;//是否开启缓存
$smarty_cache_lifetime=3600;//缓存时间
if(isset($_GET['jsonp'])){
	if(!defined("ALLOW_ORIGIN")){
		define("ALLOW_ORIGIN","*");
	}
	header("Access-Control-Allow-Origin: ".ALLOW_ORIGIN);
}
require("./skymvc/skymvc.php");
//用户自定义初始化函数
function userinit(&$base){
 
	$base->loadConfig("table");		
	$base->smarty->assign("skins","/themes/kucunadmin/");
	$base->smarty->assign("appindex",APPINDEX);
	$base->smarty->assign("appadmin",APPADMIN);
	$base->smarty->assign("appkoudai",APPKOUDAI);
	$base->smarty->assign("appkucun",APPKUCUN);
	if(!$_SESSION['sskucunadmin']){
		if((isset($_COOKIE['kc_authcode']) or get_post('kc_authcode') ) && get('m')!="login"){			 
			M('login')->kc_CodeLogin();
		}else{
			if(!in_array(get('m'),array('login','register',''))){
				header("Location: ".APPKUCUN."?m=login");		
			}		 
				 
		}
		
	}
	 
	if(isset($_SESSION['ssuser']['userid'])){
		$base->ssuser=$_SESSION['ssuser'];//当前登录用户的信息
		$base->smarty->assign("ssuser",$base->ssuser);
	}
	 
	$base->smarty->assign("sskucunadmin",$_SESSION['sskucunadmin']);
	if($_SESSION['sskucunadmin']){
		M("kucun_admin_log")->insert(array(
			"dateline"=>time(),
			"adminid"=>$_SESSION['sskucunadmin']['adminid'],
			"content"=>base64_encode(json_encode($_REQUEST)),
			"m"=>get_post('m','h'),
			"a"=>get_post('a','h'),
			"ip"=>ip()
		));
		define("SITEID",max(1,$_SESSION['sskucunadmin']['siteid']));
		define("SHOPID",max(1,$_SESSION['sskucunadmin']['shopid']));
		define("ADMINID",max(1,$_SESSION['sskucunadmin']['adminid']));
		define("ADMINTYPEID",max(1,$_SESSION['sskucunadmin']['typeid']));
	}else{
		define("SHOPID",0);
	}
}

?>